<?php 
$companyid=$session->read("companyid");
$user=$session->read('User');
//$isflag=$action->checkPermissions($user,$companyid,$type="add");
?>
<div class="right_side_operate_area">
	<div class="right_side_title left">
		<h2>
			<?php 
			$companyname=$session->read("companyname");
			echo $html->link($companyname,"/companys/showinfosummary/".$companyid);
			?>
		</h2>
		<div class="clear"></div>
	</div>
   <?php 
    	//if($isflag){
    	if(classregistry::init('User')->personAuthority($user)){
    		echo '<div class="right item_add_btn">';
			echo $html->link(__("Add",true),'editpatent');
			echo '</div>';
    	}
		//}else{
		//	echo '<div class="right enableaction">';
			//echo "<a>添加</a>";
			//echo '</div>';
		//}
	?>
    <?php
	if($showpage==1)
	{
		if(isset($paging)){ echo $this->renderElement('pagination',$paging);} 
	}
	?>
    <div class="clear"></div>
    <div class="right_sidt_head_screen">
    	<div class="left">
		 
			<div class="right_side_head_line">
				<ul>
					<?php foreach($patenttype as $statekey=>$patype){
						$indexstr=$str->getstausstr($statekey);
					?>
					<li style="margin:auto;width:auto">
						<div class="left screen_condition"><?php echo $indexstr?>：</div>
					</li>
					
						<!-- 显示每种状态的四种专利类型 start -->
						<?php 
						
							foreach($patype as $key=>$ptype){
								$selected="";
								if(isset($_GET['state']) && isset($_GET['ptype'])){
									if($statekey == $_GET['state'] &&  $key==$_GET['ptype'] ){
										$selected="selected";
									}
								}	
						?>
						<li class="<?php echo $selected?>" style="width:auto;margin-right:20px;">
							<div class="left screen_condition"><?php echo $html->link($patentname[$key],"/companys/patents?state=$statekey&ptype=".$key)?>：</div>
							<div class="left screen_counts"><?php echo $ptype;?>个</div>
							<div class="clear"></div>
						</li>
						<?php }?>
						<div class="clear"></div>
						<!-- 显示每种状态的四种专利类型 end -->
						
					<?php }?>
					<div class="clear"></div>
				</ul>
			</div>
			
		</div>
		<div class="right display_by_year_btn"><?php echo $html->link('按年度显示',"/companys/timepatents/",null,null); ?></div>
		<div class="clear"></div>
	</div>
</div>
<div class="right_side_scollbar">
	<div class="detail_info_panel">
		<div class="items_list" id='panel'>
        	<table>
            	<tr>
            		<th><?php echo '知识产权'; ?></th>
                    <th><?php echo '产权类型' ;?></th>
                    <th><?php echo '产权状态/时间' ;?></th>
                    <th><?php echo '创建时间'; ?></th>
                    <th><?php __("Action")?></th>
                </tr>
                <?php 
                $cuser=$session->read('User');
				foreach($patents as $patent){
					$id=$patent["CompanyPatent"]["id"];
					echo "<tr class='per_list'>";
					echo "<td>".$html->link($patent['CompanyPatent']['pname'],"/companys/showpatent/".$id)."</td>";
					
					echo "<td>".$patent['type_id']['value']."</td>";
					$status=$patent["CompanyPatent"]["state"];
					$apply_time=$patent["CompanyPatent"]["apply_time"];
					$accept_time=$patent["CompanyPatent"]["accept_time"];
					$authorize_time=$patent["CompanyPatent"]["authorize_time"];
					$buy_time=$patent["CompanyPatent"]["buy_time"];
					echo "<td>".$str->getstaus($status)."/";
					echo $str->getstaustime($status, $apply_time, $accept_time, $authorize_time, $buy_time)."</td>";
					$created=$patent["CompanyPatent"]["created"];
					$created=date("Y-m-d",strtotime($created));
					echo "<td>".$created."</td>";
					echo "<td>";
					if(classregistry::init('User')->personAuthority($user)&&classregistry::init('Company')->personAuthority($patent)){
						echo $html->link(__("Edit",true),"/companys/editpatent/".$id,null,null);
						echo $html->link(__("Delete",true),"/companys/delpatent/".$id,array("onclick"=>"return doaction(this)"));
					}else{
						echo "<span class='enableaction'>编辑</span>";
						echo "<span class='enableaction'>删除</span>";
					}
					echo "</td>";
					echo "</tr>";
				}?>
            </table>
		</div>
    </div>
</div>
<?php echo $this->element('actionconfirm',array("title"=>"删除提示","message"=>"你确定要删除吗？")) ?>
<script>
$(document).ready(function(){
	$(".screen_condition a").click(function(){
		$(".screen_condition a").attr("style","color:#2989E2");
		$(this).attr("style","color:#D43737");
	});	
});
</script>